package com.yuexunit.operationman.nbsy.module.SurgicalReceipt.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.config.AppConfig;
import com.yuexunit.operationman.nbsy.module.SurgicalReceipt.Bean.SurgicalReceiptBean;
import com.yuexunit.operationman.nbsy.module.SurgicalReceipt.ui.Act_SurgicalReceipt_Preview;

import org.kymjs.kjframe.ui.KJFragment;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by chenss on 2017/7/27 0027.
 */

public class Fragment_SR_Operate extends KJFragment {

    @Bind(R.id.frag_sr_op01)
    TextView fragSrOp01;
    @Bind(R.id.frag_sr_op02)
    TextView fragSrOp02;
    @Bind(R.id.frag_sr_op03)
    TextView fragSrOp03;
    @Bind(R.id.frag_sr_op04)
    TextView fragSrOp04;
    @Bind(R.id.frag_sr_op05)
    TextView fragSrOp05;
    @Bind(R.id.frag_sr_op06)
    TextView fragSrOp06;
    @Bind(R.id.frag_sr_op07)
    TextView fragSrOp07;
    @Bind(R.id.textView4)
    TextView textView4;
    @Bind(R.id.frag_sr_op08)
    TextView fragSrOp08;
    @Bind(R.id.frag_sr_op09)
    TextView fragSrOp09;
    @Bind(R.id.frag_sr_op10)
    TextView fragSrOp10;
    @Bind(R.id.frag_sr_op11)
    TextView fragSrOp11;
    @Bind(R.id.frag_sr_op12)
    TextView fragSrOp12;
    @Bind(R.id.frag_sr_op13)
    TextView fragSrOp13;
    @Bind(R.id.frag_sr_op14)
    TextView fragSrOp14;
    @Bind(R.id.frag_sr_op15)
    TextView fragSrOp15;
    private Act_SurgicalReceipt_Preview aty;
    protected View mMainView;

    @Override
    protected View inflaterView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
        aty = (Act_SurgicalReceipt_Preview) getActivity();
        mMainView = inflater.inflate(R.layout.fragment_sr_operate, container, false);
        ButterKnife.bind(this, mMainView);
        return mMainView;
    }

    protected void initData() {
        for (SurgicalReceiptBean.ObjectEntity.HandoverItemListEntity p : AppConfig.SURGICALRECEIPTBEAN.getObject().getHandoverItemList()) {
            switch (p.getItemCode()) {
                case "SF_ShenFenQueRen":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            fragSrOp01.setText("是");
                        }
                        else {
                            fragSrOp01.setText("否");
                        }
                    }
                    break;
                case "SF_YiShi":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.surgicalreceipt_sf_01);
                        if (skin[0].equals("1")) {
                            fragSrOp02.setText(arrays[0]);
                        }
                        if (skin[1].equals("1")) {
                            fragSrOp02.setText(arrays[1]);
                        }
                        if (skin[2].equals("1")) {
                            fragSrOp02.setText(arrays[2]);
                        }
                        if (skin[3].equals("1")) {
                            fragSrOp02.setText(arrays[3]);
                        }
                        if (skin[4].equals("1")) {
                            fragSrOp02.setText(arrays[4]);
                        }
                        if (skin[5].equals("1")) {
                            fragSrOp02.setText(arrays[4]);
                        }
                    }
                    break;
                case "SF_ShenMingTiZheng":
                    if(p.getItemValue().length() > 0)
                    {
                        String[] skin = p.getItemValue().split(";", -1);
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.surgicalreceipt_sf_02);
                        if(skin[0].equals("1"))
                        {
                            content+=arrays[0];
                        }

                        if(skin[1].equals("1"))
                        {
                           if(content.length() > 0)
                           {
                               content += "\n";
                               content += arrays[1];
                           }
                        }
                        fragSrOp03.setText(content);
                    }
                    break;
                case "SF_YaChuang":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            fragSrOp04.setText("无");
                        }
                        if (skin[1].equals("1")) {
                            fragSrOp04.setText("有"+"\n"+skin[2]+"\n"+skin[3]);
                        }
                    }
                    break;
                case "SF_XueZhiPin":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            fragSrOp05.setText("无");
                        }
                        if (skin[1].equals("1")) {
                            fragSrOp05.setText("有");
                        }
                    }
                    break;
                case "SF_Guandao":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.surgicalreceipt_bs_04);
                        if (skin[0].equals("1")) {
                            content+="无";
                        }
                        if (skin[1].equals("1")) {
                            content+="有";
                            if (skin[2].equals("1")) {
                                content += "\n";
                                content +=arrays[0]+"长度"+skin[11]+"cm";
                            }
                            if (skin[3].equals("1")) {
                                content += "\n";
                                content +=arrays[1];
                            }
                            if (skin[4].equals("1")) {
                                content += "\n";
                                content +=arrays[2];
                            }
                            if (skin[5].equals("1")) {
                                content += "\n";
                                content +=arrays[3];
                            }
                            if (skin[6].equals("1")) {
                                content += "\n";
                                content +=arrays[4];
                            }
                            if (skin[7].equals("1")) {
                                content += "\n";
                                content +=arrays[5]+"数量"+skin[12]+"根";
                            }
                            if (skin[8].equals("1")) {
                                content += "\n";
                                content +=arrays[6];
                            }
                            if (skin[9].equals("1")) {
                                content += "\n";
                                content +=arrays[7];
                            }
                            if (skin[10].equals("1")) {
                                content += "\n";
                                content +=arrays[8];
                            }
                        }

                        if(p.getItemOther().length() > 0)
                        {
                            content += "\n";
                            content +="其他:"+p.getItemOther();
                        }
                        fragSrOp06.setText(content);
                    }
                    break;
                case "SF_ZhiTongBeng":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            fragSrOp07.setText("无");
                        }
                        if (skin[1].equals("1")) {
                            fragSrOp07.setText("有");
                        }
                    }
                    break;
                case "SF_ZiLiao":
                    if (p.getItemValue().length() > 0) {
                        fragSrOp08.setText(p.getItemValue());
                    }
                    break;
                case "SF_XiYangFangShi":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.surgicalreceipt_sf_03);
                        if (skin[0].equals("1")) {
                            fragSrOp09.setText(arrays[0]);
                        }
                        if (skin[1].equals("1")) {
                            fragSrOp09.setText(arrays[1]);
                        }
                        if (skin[2].equals("1")) {
                            fragSrOp09.setText(arrays[2]);
                        }
                        if (skin[3].equals("1")) {
                            fragSrOp09.setText(arrays[3]);
                        }
                        if (skin[4].equals("1")) {
                            fragSrOp09.setText(arrays[4]);
                        }
                        if (skin[5].equals("1")) {
                            fragSrOp09.setText(arrays[5]);
                        }
                        if (skin[6].equals("1")) {
                            fragSrOp09.setText(arrays[6]);
                        }
                    }
                    break;
                case "SF_Other":
                    if (p.getItemOther().length() > 0) {
                        fragSrOp10.setText(p.getItemOther());
                    }
                    break;
                case "SF_JingMaiTongLu":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.surgicalreceipt_bs_05);
                        if (skin[0].equals("1")) {
                            content += arrays[0];
                        }
                        if (skin[1].equals("1")) {
                            content += "\n";
                            content += arrays[1];
                        }
                        if (skin[2].equals("1")) {
                            content += "\n";
                            content += arrays[2];
                        }
                        if (skin[3].equals("1")) {
                            content += "\n";
                            content += arrays[3];
                        }
                        if (skin[4].equals("1")) {
                            content += "\n";
                            content += arrays[4];
                        }

                        if (p.getItemOther().length() > 0) {
                            content += "\n";
                            content += "未用完的药名:" + p.getItemOther();
                        }
                        if (skin[5].length()>0) {
                            content += "\n";
                            content += "液体速度(滴/分):"+skin[5];
                        }

                        fragSrOp15.setText(content);
                    }
                    break;
            }
        }
        if(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getSfOrNurseUrl() != null){
            fragSrOp11.setText(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getSfOrNurse());
            fragSrOp12.setText(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getSfOrNurseTimeStr());
        }
        if(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getSfRrNurseUrl() != null){
            fragSrOp13.setText(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getSfRrNurse());
            fragSrOp14.setText(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getSfRrNurseTimeStr());
        }
    }
}
